From 41599e5e90b03e5ffa9579337500f9e2ecf690f4 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 8 Nov 2021 15:37:08 +0800 Subject: [PATCH] GDK-Win32: Make EGL a runtime opt-in Use the debug envvar 'GDK_DEBUG=gl-egl' to determine whether we want to try to initialize EGL first before trying WGL, as a means for people to more easily enable EGL support on Windows to test EGL there (such as to debug the shaders, for instance) --- gdk/win32/gdkdisplay-win32.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index dd40b5c13a..d4a275ec7f 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1152,21 +1152,23 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display, if (display_win32->dummy_context_wgl.hdc == NULL) display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd); - /* No env vars set, do the regular GL initialization, first WGL and then EGL, + /* + * No env vars set, do the regular GL initialization, first WGL and then EGL, * as WGL is the more tried-and-tested configuration. */ -/* - * Disable defaulting to EGL for now, since shaders need to be fixed for - * usage against libANGLE EGL. EGL is used more as a compatibility layer - * on Windows rather than being a native citizen on Windows - */ -#if 0 - result = gdk_display_init_egl (display, - EGL_PLATFORM_ANGLE_ANGLE, - display_win32->dummy_context_wgl.hdc, - FALSE, - error); +#ifdef HAVE_EGL + /* + * Disable defaulting to EGL for now, since shaders need to be fixed for + * usage against libANGLE EGL. EGL is used more as a compatibility layer + * on Windows rather than being a native citizen on Windows + */ + if (_gdk_debug_flags & GDK_DEBUG_GL_EGL) + result = gdk_display_init_egl (display, + EGL_PLATFORM_ANGLE_ANGLE, + display_win32->dummy_context_wgl.hdc, + FALSE, + error); #endif if (!result) -- 2.30.2